<script setup lang="ts">
import {useRouter} from "vue-router";

const router = useRouter();
const navigateToHome = () => {
  router.push('/')  // 跳转到⾸⻚
}
const navigateToSearch1 = () => {
  router.push({
    name: 'search',
    query: {keyword: 'c++', page: 10}
  })
}

const navigateToSearch2 = () => {
  router.push({
    name: 'search2',
    params: {keyword: 'c#', page: 20},
  })
}
const goBack = () => {
  router.go(-1) // 后退⼀步
  // 或者 router.back()
}


</script>

<template>
  <div class="about">
    <h3>about页面组件</h3>
    <div>
      <button @click="navigateToHome">去⾸⻚</button>
      <button @click="navigateToSearch1">去搜索1⻚⾯</button>
      <button @click="navigateToSearch2">去搜索2⻚⾯</button>
      <button @click="goBack">返回</button>
    </div>
  </div>
</template>

<style scoped>

</style>
